#define __encoder_c

#include "includeAll.h"


void GetEncoder()
{


    static bit encoderSta;
    static bit  encodersta2;
    static bit lastEncoderA;
    static bit lastEncoderB;
	static bit lastEncoderC;
    static uint16_t mask=0x0001;
    


    if(D_EncoderA&&D_EncoderB)
    {
        encoderSta=1;
    }
   if(encoderSta==1)
    {
        if((D_EncoderA==0)&&(D_EncoderB==0))
        {
				
            if(lastEncoderB)
            {
                encoderSta=0;
				if((bPowerOnOff)&&(bError==0))
				{
					
					if((setTemp<75)&&(bSetTemp))
					{
						flashSetTemptime=12;
						Buzz(25);
						setTemp++;
					}
					
					if(bSetTemp==0)
					{
						Buzz(25);
						flashSetTemptime=12;
					}
					
					
					bSetTemp=1;
				}
				
            }
            if(lastEncoderA)
            {
                encoderSta=0;
              	if((bPowerOnOff)&&(bError==0))
				{
					if((setTemp>30)&&(bSetTemp))
					{
						flashSetTemptime=12;
						Buzz(25);
						setTemp--;
					}
					
					if(bSetTemp==0)
					{
						Buzz(25);
						flashSetTemptime=12;
					}
					
					
					bSetTemp=1;
				}
			}
            }
		}
	
	
	//	F_setH();
	//	F_setC();
	//	F_setG();
    if((D_EncoderC==0)&&(lastEncoderC==1))
    {
		
        encodersta2=1;
    }
    if(encodersta2)
    {
        mask=mask<<1;
        if(mask==0x0080)
        {
            encodersta2=0;
						Buzz(50);
					if(bPowerOnOff)
					{
						PowerOff();
					}
					else
					{
						bPowerOnOff=1;
					}
						
            mask=0x0001;
			
        }
    }
    else
    {
        encodersta2=0;
        mask=0x0001;
    }

    lastEncoderA=D_EncoderA;
    lastEncoderB=D_EncoderB;
     lastEncoderC=D_EncoderC;
}

